// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-25

package services

import (
	"context"
	"gitee.com/go-libs/db-xorm/db"
	"server/app/http/models"
)

// Paging
// 订单分页.
func (o *OrderArcadeService) Paging(ctx context.Context, data map[string]any, page, size int) (list []*models.OrderArcade, total int64, err error) {
	var sess *db.Session
	if sess, err = o.Dao.Slaver(ctx); err == nil {
		if total, err = sess.Where(data).Count(models.OrderArcade{}); err == nil && total > 0 {
			err = sess.Where(data).OrderBy("created_at DESC").Limit(size, (page-1)*size).Find(&list)
		}
	}
	return
}
